package com.ddwl.user.controller;

import com.ddwl.common.annotation.Auth;
import com.ddwl.common.constant.BaseEnum;
import com.ddwl.common.controller.BaseController;
import com.ddwl.schema.vo.base.RestVo;
import com.ddwl.user.service.WxUserInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Author hemiaojun
 * @Date 2021/6/11 9:45
 */
@Api("微信")
@RestController
@RequestMapping("/wxUserInfo")
public class WxUserInfoController extends BaseController {

    @Resource
    private WxUserInfoService wxUserInfoService;


    @GetMapping("/syncWxUserInfo")
    @ApiOperation("同步微信用户信息")
    @Auth(product = BaseEnum.ProductEnum.CONSOLE)
    public RestVo syncWxUserInfo() {
        wxUserInfoService.syncWxUserInfo();
        return RestVo.ok();
    }

    @GetMapping("/subscribeNotify")
    @ApiOperation("用户关注公众号通知")
    public String subscribeNotify(HttpServletRequest request, HttpServletResponse response){
        return wxUserInfoService.processNotify(request,response);
    }

}
